package org.apogee.mil.client.main.pages.trainer;

import org.apogee.mil.client.main.pages.trainer.widgets.TrainerMessageWidget;
import org.apogee.mil.client.main.pages.trainer.widgets.ViewTraineeWidget;
import org.apogee.mil.client.widgets.DialogHelper;

import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.HorizontalPanel;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.button.Button;
import com.extjs.gxt.ui.client.widget.form.FormPanel;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.google.gwt.user.client.Element;

public class TrainerPanel extends LayoutContainer {
	
	@Override
	public void onRender(Element parent, int index) {
		super.onRender(parent, index);
		
		setLayout(new FitLayout());
		setWidth(400);
		setHeight(400);
		
		FormPanel fp = new FormPanel();
		fp.setHeading("Trainer");
		fp.setBorders(true);
		fp.setFrame(true);
		
		HorizontalPanel hp = new HorizontalPanel();
		hp.setStyleAttribute("padding", "10px");
		
		Button button = new Button("View Trainees");
		button.setStyleAttribute("padding", "10px");
		button.setWidth(150);
		button.addSelectionListener(new SelectionListener<ButtonEvent>() {
			
			@Override
			public void componentSelected(ButtonEvent ce) {
				DialogHelper dh = new DialogHelper("", new ViewTraineeWidget().asWidget());
				dh.show();		
			}
		});
		
		hp.add(button);
		
		button = new Button("Write Message");
		button.setStyleAttribute("padding", "10px");
		button.setWidth(150);
		button.addSelectionListener(new SelectionListener<ButtonEvent>() {
			
			@Override
			public void componentSelected(ButtonEvent ce) {
				DialogHelper dh = new DialogHelper("", new TrainerMessageWidget().asWidget());
				dh.show();
			}
		});
		
		hp.add(button);
		
		ContentPanel cp = new ContentPanel();
		cp.setBorders(true);
		cp.setHeading("Trainer Options");
		cp.add(hp);
		
		fp.add(cp);
		
		add(fp);
	}

}
